package 反转链表;

public class Solution {
    public ListNode ReverseList(ListNode head) {
        //pre指针:用来指向反转后的节点，初始化为null
        ListNode pre = null;
        //当前节点指针
        ListNode cur = head;
        while (cur != null){
            ListNode newNode = cur.next;
            cur.next = pre;
            pre = cur;
            cur = newNode;
        }
        return pre;
    }
}
